<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page language="java" import="net.sf.rose.business.bean.base.Group" %>
<%@ page language="java" import="java.util.List" %>
<%@include file="/common/header.jsp"%>
<c:set var="path" value="..${ctx}/define/menu"/>

<form id="define_menu_list" method="post" action="${path}/list.html">
</form>

<div id="resultBox"></div>

	<div class="panelBar">
		<ul class="toolBar">
			<li><a class="add" onclick="return addmenu();" title="添加菜单信息"><span>添加</span></a><br /><br /></li>
			<li class="line">line</li>
			<li><a class="edit" onclick="return editmenu();" title="修改菜单信息"><span>修改</span></a></li>
			<li class="line">line</li>
			<li><a class="edit" onclick="return savemenu();" title="保存菜单信息"><span>保存</span></a></li>
			<li class="line">line</li>
			<li><a class="delete" onclick="return deletemenu();" title="确定要删除吗?"><span>删除</span></a></li>
			<li class="line">line</li>
			<li><a class="edit" onclick="inputMenu('导入数据库');" title="导入数据库"><span>导入数据库</span></a></li>
			<li class="line">line</li>
			<li><a class="edit" onclick="ouputMenu('导出数据库');" title="导出数据库"><span>导出数据库</span></a></li>
		</ul>
	</div>

<div style=" float:left; display:block; margin:10px; overflow:auto; width:800px; height:300px; border:solid 1px #CCC; line-height:21px; background:#FFF;">
<!-- expand collapse -->
<ul class="tree treeFolder expand">
	<%
	String group = (String) request.getAttribute("group");
	out.print(group);%>
</ul>
</div>

<script type="text/javascript">
var treeid = null;
function treeClick(id){
	treeid = id;
}

function addmenu(){
	if(treeid == null){
		alertMsg.warn('请先选择一个父菜单！');
		return;
	}
	var url = "${path}/add.html?parent=" + treeid;
	//打开dialog
	$.pdialog.open(url, "base_define_menu_add", '新增菜单',{width:760,height:460,mask:true,maxable:false,resizable:true});
}

function editmenu(){
	if(treeid == null){
		alertMsg.warn('请先选择要编辑的菜单！');
		return;
	}
	var url = '${path}/edit.html?node=' + treeid;
	//打开dialog
	$.pdialog.open(url, "base_define_menu_add", '修改菜单',{width:760,height:460,mask:true,maxable:false,resizable:false});
}

function savemenu(){
	var url = '${path}/saveAll.html';
	$.ajax({
		type: "post", url: url,
		dataType: "json",
		success: function(rs){
			if(rs.statusCode =="200")
			{
				alertMsg.correct(rs.message);
			}else{
				alertMsg.warn(rs.message);
				return false;
			}
		},
		error: function(){
			alertMsg.error('系统错误，请联系管理员！');
		}
	});
	// var url = '../office/base/group/save.html';
	// 打开dialog
	// $.pdialog.open(url, "group_save", '新增',{width:800,height:550,mask:true,maxable:false,resizable:false});
}

function deletemenu(){
	if(treeid == null){
		alertMsg.warn('请先选择要删除的菜单！');
		return;
	}
	alertMsg.confirm("确认删除吗？", {
		okCall: function(){
			var url = '${path}/delete.html?node=' + treeid;
			$.ajax({
				type: "post", url: url,
				dataType: "json",
				success: function(rs){
					if(rs.statusCode =="200")
					{
						navTab.reload('${path}/list.html');//刷新
						alertMsg.correct(rs.message);
					}else{
						alertMsg.warn(rs.message);
						return false;
					}
				},
				error: function(){
					alertMsg.error('系统错误，请联系管理员！');
				}
			});
		}
	});
}

function inputMenu(title){
	var url = "..${ctx}/upload/view.html?js_back_function=inputMenuConsultBack";
	//window.open (url, "newwindow", "height=300, width=600, toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no") //写成一行
	$.pdialog.open(url, "base_define_database_inportxls", title,{width:720,height:380,mask:true,maxable:false,resizable:true});
}

function inputMenuConsultBack(){
	var url = "${path}/input.html";
	$.ajax({
		type: "post", url: url,
		success: function(rs){
			alertMsg.correct(rs.message);
		},
		error: function(){
			alertMsg.error('系统错误，请联系管理员！');
		}
	});
}

function ouputMenu(title){
	var url = "${path}/output.html";
	window.open (url, "newwindow", "height=300, width=600, toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no") //写成一行
	//$.pdialog.open(url, "base_define_database_outportxls", title,{width:720,height:380,mask:true,maxable:false,resizable:true});
}
</script>
